﻿

using System;

public class TimeManager
{
    public int FrameCount { get; private set; }

    public float DeltaTime { get; private set; }

    public float TimeScinceLevelLoad { get; private set; }

    public float RealTimeSinceStartUp
    {
        get
        {
            if (bStart)
            {
                return (float)((DateTime.Now - m_InitTime).TotalSeconds);
            }
            else
            {
                return -1;
            }
        }
    }

    public long RealTimeSinceStartUpMS
    {
        get
        {
            if (bStart)
            {
                return (long)((DateTime.Now - m_InitTime).TotalMilliseconds);
            }
            else
            {
                return -1;
            }

        }
    }

    private DateTime m_InitTime;

    private DateTime m_LastFrameTime;

    private bool bStart;

    public void Start()
    {
        m_InitTime = DateTime.Now;
        m_LastFrameTime = DateTime.Now;
        bStart = true;
    }

    public void Update()
    {
        DateTime now = DateTime.Now;
        DeltaTime = (float)((now - m_LastFrameTime).TotalSeconds);
        FrameCount++;
        m_LastFrameTime = now;
    }

    public void Clear()
    {
        FrameCount = 0;
        DeltaTime = 0;
        TimeScinceLevelLoad = 0;
        bStart = false;
    }


}